<script lang="ts" setup>
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
  User,
  Goods,
  Key,
  House,
  PieChart,
  List,
  Plus,
  Edit,
  View,
  SwitchButton,
  Delete,
  Search,
  Share,
  Upload
} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { ref,reactive,onMounted } from 'vue'
const router=useRouter();
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}

let UserName=ref();
onMounted(()=>{
  UserName.value=sessionStorage.getItem("UserName")
})

const logout = () => {
  sessionStorage.removeItem("Token")
  sessionStorage.removeItem("UserName")
  router.push('/UserinfoLogn')
}
</script>

<template>
  <div class="app-container">
    <el-container class="main-container">
      <!-- 顶部导航栏 -->
      <el-header class="app-header">
        <div class="header-content">
          <div class="logo-section">
            <el-icon class="logo-icon"><House /></el-icon>
            <h1 class="app-title">智慧酒店管理系统</h1>
          </div>
          <div class="user-section">
            <el-avatar :size="40" class="user-avatar">
              <el-icon><User /></el-icon>
            </el-avatar>
            <span class="username">欢迎：{{ UserName }}</span>
            <el-button 
              type="danger" 
              size="small" 
              @click="logout"
              class="logout-btn"
            >
              <el-icon><SwitchButton /></el-icon>
              退出登录
            </el-button>
          </div>
        </div>
      </el-header>

      <el-container class="content-container">
        <!-- 侧边菜单栏 -->
        <el-aside width="250px" class="app-aside">
          <el-menu
            default-active="2"
            router
            class="app-menu"
            @open="handleOpen"
            @close="handleClose"
            background-color="#001529"
            text-color="#fff"
            active-text-color="#409EFF"
          >
            <el-sub-menu index="1">
              <template #title>
                <el-icon><User /></el-icon>
                <span>用户管理</span>
              </template>
              <el-menu-item index="/UserList">
                <el-icon><List /></el-icon>
                <span>用户列表</span>
              </el-menu-item>
              <el-menu-item index="/UserAdd">
                <el-icon><Plus /></el-icon>
                <span>用户添加</span>
              </el-menu-item>
            </el-sub-menu>

            <el-sub-menu index="2">
              <template #title>
                <el-icon><Goods /></el-icon>
                <span>商品管理</span>
              </template>
              <el-menu-item index="/GoodsAdd">
                <el-icon><Plus /></el-icon>
                <span>商品添加</span>
              </el-menu-item>
              <el-menu-item index="/GoodsList">
                <el-icon><List /></el-icon>
                <span>商品显示</span>
              </el-menu-item>
              <el-menu-item index="/Goodchart">
                <el-icon><PieChart /></el-icon>
                <span>商品图表信息</span>
              </el-menu-item>
            </el-sub-menu>

            <el-sub-menu index="3">
              <template #title>
                <el-icon><Key /></el-icon>
                <span>权限管理</span>
              </template>
              <el-menu-item index="/RABCAdd">
                <el-icon><Plus /></el-icon>
                <span>用户角色添加</span>
              </el-menu-item>
              <el-menu-item index="/RBACList">
                <el-icon><List /></el-icon>
                <span>权限显示</span>
              </el-menu-item>
            </el-sub-menu>

            <el-sub-menu index="4">
              <template #title>
                <el-icon><House /></el-icon>
                <span>房型管理</span>
              </template>
              <el-menu-item index="/OrderinfoList">
                <el-icon><List /></el-icon>
                <span>房型信息</span>
              </el-menu-item>
              <el-menu-item index="/Orderinfocarousel">
                <el-icon><View /></el-icon>
                <span>房型轮播图</span>
              </el-menu-item>
            </el-sub-menu>
          </el-menu>
        </el-aside>

        <!-- 主内容区域 -->
        <el-main class="app-main">
          <div class="main-content">
            <RouterView />
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped>
.app-container {
  height: 100vh;
  background: #f0f2f5;
}

.main-container {
  height: 100vh;
}

.app-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: 70px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 20px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  font-size: 32px;
  color: #fff;
}

.app-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  color: #fff;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-avatar {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.username {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.content-container {
  height: calc(100vh - 70px);
}

.app-aside {
  background: #001529;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
}

.app-menu {
  border: none;
  height: 100%;
}

.app-menu .el-sub-menu__title {
  height: 50px;
  line-height: 50px;
  font-size: 16px;
  font-weight: 500;
}

.app-menu .el-menu-item {
  height: 45px;
  line-height: 45px;
  font-size: 14px;
  margin: 2px 0;
  border-radius: 6px;
  margin-left: 10px;
  margin-right: 10px;
}

.app-menu .el-menu-item:hover {
  background-color: #1890ff !important;
  color: #fff !important;
}

.app-menu .el-menu-item.is-active {
  background-color: #1890ff !important;
  color: #fff !important;
}

.app-menu .el-sub-menu__title:hover {
  background-color: #1890ff !important;
  color: #fff !important;
}

.app-main {
  background: #f0f2f5;
  padding: 20px;
  overflow-y: auto;
}

.main-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-height: calc(100vh - 130px);
  padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-aside {
    width: 200px !important;
  }
  
  .app-title {
    font-size: 20px;
  }
  
  .username {
    display: none;
  }
  
  .main-content {
    padding: 15px;
  }
}

@media (max-width: 576px) {
  .app-aside {
    width: 180px !important;
  }
  
  .app-title {
    font-size: 18px;
  }
  
  .logo-icon {
    font-size: 24px;
  }
}

/* 滚动条样式 */
.app-aside::-webkit-scrollbar {
  width: 6px;
}

.app-aside::-webkit-scrollbar-track {
  background: #001529;
}

.app-aside::-webkit-scrollbar-thumb {
  background: #1890ff;
  border-radius: 3px;
}

.app-aside::-webkit-scrollbar-thumb:hover {
  background: #40a9ff;
}

.app-main::-webkit-scrollbar {
  width: 8px;
}

.app-main::-webkit-scrollbar-track {
  background: #f0f2f5;
}

.app-main::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 4px;
}

.app-main::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}
</style> 